<!DOCTYPE html>
<html lang="zh">
<head>
	<meta charset="UTF-8">
	<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"> 
	<meta name="viewport" content="width=device-width, initial-scale=1.0">
	<title>login</title>
	<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.5.0/css/font-awesome.min.css">
    <link rel="stylesheet" href="./css/bootstrap.min.css">
    <link rel="stylesheet" href="./css/login.css">
	<!--[if IE]>
		<script src="http://cdn.bootcss.com/html5shiv/3.7.3/html5shiv.min.js"></script>
	<![endif]-->
</head>
<body style="background-color: #00b4ef;">
	<div class="htmleaf-container" id="login">
		<div class="demo form-bg" style="padding-top: 15rem;">
            <div class="container">
                <div class="row">
                    <div class="col-md-offset-3 col-md-6">
                        <form class="form-horizontal">
                            <span class="heading">用户登录</span>
                            <div style="color: red;display: none;">
                                <span id="usernameErrMsg">用户名不正确</span>
                            </div>
                            <div class="form-group">
                                <input type="text" class="form-control" id="username" placeholder="用户名">
                                <i class="fa fa-user"></i>
                            </div>
                            <div style="color: red;display: none;">
                                <span id="passwordErrMsg">用户名不正确</span>
                            </div>
                            <div class="form-group help">
                                <input type="password" class="form-control"id="password" placeholder="密　码">
                                <i class="fa fa-lock"></i>
                                <a href="#" class="fa fa-question-circle"></a>
                            </div>
                            <div class="form-group">
                                <div class="main-checkbox">
                                    <input type="checkbox" id="checkbox1" name="check" onchange="update();"/>
                                    <label for="checkbox1"></label>
                                </div>
                                <span class="text">Remember me</span>
                                <button type="submit" id="submit" class="btn btn-default">登录</button>
                            </div>
                        </form>
                    </div>
                </div>
            </div>
        </div>
    </div>
    
    <script src="js/vendor/jquery-2.2.4.min.js"></script>
    <script>
        var remember = false;
        function update(){
            remember = !remember;
        }

        function submit(){
            var username = $("#username").val();
            var password = $("#password").val();
            alert(123)
            console.log(username);
            console.log(password);
            console.log(remember);
        }

        window.onload=function(){
            var mysubmit=document.getElementById('submit');
            mysubmit.onclick=function(event){
                var username = $("#username").val();
                var password = $("#password").val();
                if(username == "" || username == "undefinde"){
                    var usernameErrMsg = $("#usernameErrMsg");
                    usernameErrMsg.html("用户名不能为空");
                    usernameErrMsg.parent().show();
                    return false;
                }
                if(password == "" || password == "undefinde"){
                    var passwordErrMsg = $("#passwordErrMsg");
                    passwordErrMsg.html("用户密码不能为空");
                    passwordErrMsg.parent().show();
                    return false;
                }
                console.log(username);
                console.log(password);
                console.log(remember);
                window.location.href = "./main.html"
                return false;
            }
        }
    </script>
</body>
</html>